<?php
set_time_limit(0);
if (isset($_POST['op']) && isset($_POST['kong'])){
    include '../c/config.php';
    $openid=trim(addslashes($_POST['op']));
    $schoolid=trim(addslashes($_POST['ud']));
    $leftTime=trim(addslashes($_POST['leftTime']));
    $nianji=trim(addslashes($_POST['nianji']));
     
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
    $table='tian6';
    if(6 == $nianji){
        $table='tian6';
    }
    if(7 == $nianji){
        $table='tian7';
    }
    if(8 == $nianji){
        $table='tian8';
    }
    if(9 == $nianji){
        $table='tian9';
    }

    $mysqli->query("INSERT INTO `".$table."` (`id`, `uid`, `schoolid`,`kong`,`createtime`,`lefttime`,`ji`) VALUES (NULL,'".$openid."','".$schoolid."', '".json_encode($_POST['kong'], JSON_UNESCAPED_UNICODE)."','".date("Y-m-d H:i:s")."','".$leftTime."','1')");
      
 
    $mysqli->close();
    echo json_encode(array('s'=>'y'));
     
}else{
    echo json_encode(array('s'=>'n'));
}

?>